package com.hcbd.tdwt.ui.setting.xingyu.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;


import com.hcbd.tdwt.R;
import com.hcbd.tdwt.base.BaseActivity;
import com.hcbd.tdwt.base.BeidouBoxParams;
import com.hcbd.tdwt.base.Constant;

import com.hcbd.tdwt.base.bd.BdToolFactory;
import com.hcbd.tdwt.ui.common.dialog.BottomSelectDialog;
import com.hcbd.tdwt.util.SharedPreferencesUtil;


import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

import java.util.Arrays;
import java.util.List;

@SuppressLint("NonConstantResourceId")
@EActivity(R.layout.activity_audio_set)
public class AudioSetActivity extends BaseActivity {
    @ViewById
    RelativeLayout speechZip,bdEquipmentLL;
    @ViewById
    TextView roteTv,left_device_tip,title;
    private SharedPreferencesUtil sp;
    private BottomSelectDialog bottomSelectDialog;
    private String rateStr[]={"2400","1200","700","450"};
    @AfterViews
    protected void init() {
        sp=new SharedPreferencesUtil(this);
        title.setText("语音设置");
        int currentIndex =sp.getAttributeInt(Constant.ENCODER_RATE);
        roteTv.setText(rateStr[currentIndex]);
        List<String> str = Arrays.asList(rateStr);
        bottomSelectDialog=new BottomSelectDialog(this, "选择语音压缩率", str, (index, str1) -> {
            if(BeidouBoxParams.cardType==3&&index==0){
                toast("三级卡无法选择2400bps");
                return;
            }
            sp.addAttribute(Constant.ENCODER_RATE,index);
            Constant.encoderCodeRate=index;
            roteTv.setText(str1);
        });
        if(BdToolFactory.MOBILE_PHONE_TYPE==BdToolFactory.SATELLITE_MOBILE_PHONE){
            bdEquipmentLL.setVisibility(View.GONE);
            left_device_tip.setVisibility(View.GONE);
        }
    }
    @Click
    void speechZip(){
        BottomSelectDialog.show(bottomSelectDialog);
    }
    @Click
    void bdEquipmentLL(){
        Intent intent=new Intent();
        intent.setClass(this, VoiceParameterActivity_.class);
        startActivity(intent);
    }

    @Click
    void headLeft(){
        finish();
    }
}
